<?php
	session_start();
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Won-松的趣味分享</title>
	<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link href="../bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
	  <!--[if lt IE 9]>
		  <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		  <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	  <![endif]-->
	<link rel="stylesheet" type="text/css" href="../css/bass.css"/>
	<link rel="stylesheet" type="text/css" href="../css/funstyle.css"/>
	<script charset="utf-8" src="../js/kindeditor/kindeditor-all-min.js"></script>
	<script charset="utf-8" src="../js/kindeditor/lang/zh-CN.js"></script>
	<script type="text/javascript" src="../jquery.min.js"></script>
	<script type="text/javascript">
		$(function(){
			$(".del").click(function(){
				if(!confirm("确认删除？")){
					return false;
				}
			})
		})
	</script>
</head>
<body>
	<div class="wrap">
		<!--head-->
		<div class="w100">
			<!--head-top-->
			<div class="headtop w960 clearfix">
				<div class="logo fl"><a href="#"><img src="../img/logo.png"></a></div>
		<?php
			include("../function.php");
			$conn = conn();
			$resourse = mysqli_query($conn,"select * from nav");   
			while ($row = mysqli_fetch_assoc($resourse)){
		?>
				<div class="nav fl">
					<ul>
						<li class="fl ml25"><a href="<?php echo $row["addr"]?>"><?php echo $row['option']?></a></li>
					</ul>
				</div>
		<?php
			}
		?>
			</div>
			<div class="clear"></div>
			<!--head-background-->
			<div class="bg">
				<div class="title"><h2>趣味分享</h2></div>
				<ul class="clearfix">
					<li class='fl'><a href="funsharing.php">全部</a></li>
				<?php 
				$cata_id = $_GET['cata_id'];
					$resourse = mysqli_query($conn,"select * from cata_log");   
					while ($data = mysqli_fetch_assoc($resourse)){
				?>
					<li class="fl"><a href="list.php?cata_id=<?=$data["id"]?>"><?=$data["class"]?></a></li>
				<?php 
					}

				?>
				</ul>
			</div>
		</div>
		<div class="clear"></div>
		<!--main-->
		<?php
		error_reporting(E_ERROR | E_WARNING | E_PARSE);
		$s = $_SESSION["is_login"];
		if ($s=='ok') {
	?>
	<div class="form">
		<div class="head"><b>添加新闻</b></div>
		<form action="add.php" method="post" enctype="multipart/form-data">  <!--图片上传注意要在form中加enctype="multipart/form-data"-->
			<input type="hidden" name="cata_id" value="<?=$cata_id?>">
			<div><input type="text" name="title"  placeholder="标题"/></div>
			<div>分类：
				<select name="cata_id">
					<?php
						$sql = "select * from cata_log";
						$result = mysqli_query($conn,$sql);
						while ($row = mysqli_fetch_assoc($result)) {
					?>
						<option value="<?=$row['id']?>"><?=$row['class']?></option>
					<?php
						}
					?>
				</select>
			</div>
			<div><textarea  rows="3" name="desc" placeholder="简介"></textarea></div>
			<div><span style="font-size:24px; color:green;">输入内容：</span><textarea class="edit" rows="5" name="content" ></textarea></div>
			<div><input type="file" name="img"></div>
			<div><input type="submit"  /></div>
		</form>
		<script>
			KindEditor.create('.edit');
		</script>
		<?php
			}
		?>
	</div>
	<?php
		$cata_id = $_GET['cata_id'];
		$resourse = mysqli_query($conn,"select * from article where catalog_id=$cata_id order by id desc "); 
		while ($row = mysqli_fetch_assoc($resourse)){
	?>
		<div class="content w960 clearfix">
			<div class="left fl"><img style="height:220px;" src="<?php echo $row["img"]?>"></div>
			<div class="center fl">
				<a href="content.php?id=<?php echo $row['id']?>"><h2><?php echo $row["title"]?></h2></a>
				<p><?php echo $row["desc"]?></p>
			</div>
			<div class="right fl">
				<div>浏览次数：<?=$row['view']?></div>
				<div>
					<a class="btn btn-primary btn-xs" href="article_recommend.php?id=<?=$row['id']?>&recommend=<?=$row['recommend']?>&cata_id=<?=$cata_id?>">
						<?php echo $row['recommend']==0?'推荐':'已推荐'?>
					</a>
					<a class="btn btn-success btn-xs" href="edit.php?id=<?php echo $row['id']?>">编辑</a>
					<a class="del btn btn-danger btn-xs" href="del.php?id=<?php echo $row['id']?>&cata_id=<?=$row['catalog_id']?>">删除</a>
				</div>
				<div class="time"><?php echo date("Y-m-d H:i:s",$row["create_time"])?></div>
			</div>	
		</div>
	<?php
		}
	?>
	</div>
	<div class="bottom"><a href="#">置顶</a></div>
</body>
  <script src="js/bootstrap.min.js"></script>
</html>